package com.tbm.impl.service;

import com.tbm.base.service.RoleService;
import com.tbm.entity.RoleEntity;
import com.tbm.repository.RoleEntityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/8/30.
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleEntityRepository roleRepository;

    @Override
    public RoleEntity findOne(Integer roleId) {
        return roleRepository.findOne(roleId);
    }

    @Override
    public List<RoleEntity> findAll() {
        return roleRepository.findAll();
    }

    @Override
    public Page<RoleEntity> findAll(Pageable pageable) {
        return roleRepository.findAll(pageable);
    }

    @Override
    public int count(){
        return (int) roleRepository.count();
    }

    @Override
    public void save(RoleEntity roleEntity){
        roleRepository.save(roleEntity);
    }

    @Override
    public void saveAndFlush(RoleEntity roleEntity) {
        roleRepository.saveAndFlush(roleEntity);
    }

    @Override
    public void delete(Integer roleId) {
        roleRepository.delete(roleId);
    }
}
